var ws = require('nodejs-websocket')
var axios = require('axios')

var server = ws.createServer(function (conn) {
    console.log('new connection');
    conn.on('text', function (str) {
        boardcast(str)
    })
    conn.on('error', function (err) {
        console.log(err);
    })
    conn.on('close', function () {
        console.log('connection closed');
    })
}).listen(2333);
function boardcast(str) {
    server.connections.forEach(function (conn) {
        axios.post('http://localhost:3000/bjw_index/bjwlist', JSON.parse(str)).then(() => {
            conn.sendText('123')
        })                                                 
    })
}